package com.tjh.springbootapi.实例demo;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.tjh.springbootapi.entity.Menu;
import com.tjh.springbootapi.service.MenuService;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;

import java.util.ArrayList;
import java.util.List;

/**
 * Create by koala on 2020-03-21
 */
@SpringBootTest
public class UseLambdaQueryWrapper {

    @Autowired
    MenuService menuService;

    @Test
    public void testLambdaQueryWrapper() {
        String appId = "ASD5745FD545SDF5454SDF";
        List<String> idList = new ArrayList<>();
        idList.add("SDFJHA65656ASDF656SDF5");
        idList.add("5SADF5SADF45SD5F45SDF4");
        idList.add("AS545SF545AS5DF545SDFD");

        LambdaQueryWrapper<Menu> menuLambdaQueryWrapper = new LambdaQueryWrapper<>();
        menuLambdaQueryWrapper.eq(Menu::getAppId, appId);
        menuLambdaQueryWrapper.in(Menu::getId, idList);
        menuLambdaQueryWrapper.orderByAsc(Menu::getDisplayOrdinal);

        List<Menu> menus = menuService.find(menuLambdaQueryWrapper);
        System.out.println(menus);
    }

}
